-@page_title ='灰名单管理'
%p#notice= notice

-# form_for @search, url => "/xxxxxx" do |f|
  = f.label '被举报人身份证号'
  = f.text_field :citizen_id
  = f.label '被举报人姓名'
  = f.text_field :person_reported_against
  = f.label :post
  = f.text_field "posts.comments.author"
  / the associations could go even deeper, isn't it POWERFUL?
  = f.submit

%table.table.table-bordered
  %thead
    %tr
      %th 行业
      %th 被举报人
      %th 身份证号
      %th 地址
      %th 举报原因
      %th 案发时间
      %th 举报人
      %th 举报人状态
      %th 灰名单状态
      %th
  %tbody
    - @credit_records.each do |credit_record|
      %tr
        %td= credit_record.industry
        %td= credit_record.person_reported_against
        %td= credit_record.citizen_id
        %td= credit_record.address
        %td= credit_record.reported_reason
        %td= credit_record.time_of_incident
        %td= credit_record.user.realname
        %td= credit_record.user.readable_state
        %td
          %span{class: "label #{credit_record.workflow_state_class}"}= credit_record.readable_state
        %td
          = link_to '显示', credit_record, class: 'btn btn-primary'
          - if current_admin
            = link_to '删除', credit_record, class: 'btn btn-danger', method: :delete, data: { confirm: 'Are you sure?' }
          -#if admin_signed_in?
            = link_to '编辑', edit_credit_record_path(credit_record), class: 'btn btn-primary'
%br
= paginate @credit_records, :params => {:state => params[:state]}
-# link_to '添加灰名单', root_path, class: 'btn btn-primary'#new_credit_record_path, 
- if user_signed_in?
  %a.btn.btn-primary{href:"#{root_path}"}
    %i.glyphicon.glyphicon-plus-sign
    添加灰名单

